<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>RTOS - a cooperative multitasking library: RTOS::flag Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">RTOS - a cooperative multitasking library
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="class_r_t_o_s.html">RTOS</a>      </li>
      <li class="navelem"><a class="el" href="class_r_t_o_s_1_1flag.html">flag</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#friends">Friends</a>  </div>
  <div class="headertitle">
<div class="title">RTOS::flag Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="RTOS::flag" --><!-- doxytag: inherits="RTOS::waitable" -->
<p>basic synchronisation mechanism.  
 <a href="class_r_t_o_s_1_1flag.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RTOS::flag:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_r_t_o_s_1_1flag.png" usemap="#RTOS::flag_map" alt=""/>
  <map id="RTOS::flag_map" name="RTOS::flag_map">
<area href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for" alt="RTOS::waitable" shape="rect" coords="0,56,97,80"/>
<area href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened" alt="RTOS::event" shape="rect" coords="0,0,97,24"/>
</map>
 </div></div>

<p><a href="class_r_t_o_s_1_1flag-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1flag.html#a2d05d296b33e6cbc141fd4fb5e6f2740">flag</a> (<a class="el" href="class_r_t_o_s_1_1task.html">task</a> *<a class="el" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d">t</a>, const char *name=&quot;&quot;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">constructor, specify onwer and name  <a href="#a2d05d296b33e6cbc141fd4fb5e6f2740"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1flag.html#aae862c6b7c385a4920d9a486e25ad5d8">set</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">sets the flag  <a href="#aae862c6b7c385a4920d9a486e25ad5d8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a38ac8e72fcd0b7bcc45fd00acb156cbb"></a><!-- doxytag: member="RTOS::flag::print" ref="a38ac8e72fcd0b7bcc45fd00acb156cbb" args="(std::ostream &amp;s, bool header=true) const " -->
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1flag.html#a38ac8e72fcd0b7bcc45fd00acb156cbb">print</a> (std::ostream &amp;s, bool header=true) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">prints flag infomation (for debugging) <br/></td></tr>
<tr><td colspan="2"><h2><a name="friends"></a>
Friends</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa5b30b5b619f01a5d94b779bf0e58610"></a><!-- doxytag: member="RTOS::flag::RTOS" ref="aa5b30b5b619f01a5d94b779bf0e58610" args="" -->
class&#160;</td><td class="memItemRight" valign="bottom"><b>RTOS</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>basic synchronisation mechanism. </p>
<p>The basic synchronization mechanism is the (event) flag. Like all waitables, a flag is created for a particular task. A flag is set by a <a class="el" href="class_r_t_o_s_1_1flag.html#aae862c6b7c385a4920d9a486e25ad5d8" title="sets the flag">flag::set()</a> call (or the task::set( flag) call, which has the same effect). Like all waitables, when a task is waiting for a flag (using a <a class="el" href="class_r_t_o_s_1_1task.html#a6fc603d0f1c8a94813586d3dfd123fcc" title="wait for all waitables created for this task">task::wait</a> call) and that flag becomes set, the wait call will clear the flag, and return an event that compares equal to the flag. Note that a flag does not count: setting a flag that is already set has no effect on the flag.</p>
<p>A flag must be created for a specific task. The normal place to do this is in the task's creator. An flag is initially cleared.</p>
<p>The example below shows a led_task that responds to two event flags. The shift flag will cause it to shift the pattern on the LEDs one position to the left, while the invert flag will cause it to invert the pattern. Two addional tasks do notghing but set these flags at fixed intervals. The result is a sort of one-direction Kitt display, which will occasionally flip polarity. Note that in this example the wait call excplicitly mentions the flags it waits for.</p>
<div class="fragment"><pre class="fragment"> TBW
</pre></div> </div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a2d05d296b33e6cbc141fd4fb5e6f2740"></a><!-- doxytag: member="RTOS::flag::flag" ref="a2d05d296b33e6cbc141fd4fb5e6f2740" args="(task *t, const char *name=&quot;&quot;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">RTOS::flag::flag </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_r_t_o_s_1_1task.html">task</a> *&#160;</td>
          <td class="paramname"><em>t</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em> = <code>&quot;&quot;</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>constructor, specify onwer and name </p>
<p>This call creates a timer for task t. The name is used for debugging and statistics. </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aae862c6b7c385a4920d9a486e25ad5d8"></a><!-- doxytag: member="RTOS::flag::set" ref="aae862c6b7c385a4920d9a486e25ad5d8" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void RTOS::flag::set </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>sets the flag </p>
<p>Setting a flag causes the task that waits for this flag to be awakened. </p>

<p>Reimplemented from <a class="el" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e">RTOS::waitable</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sat Apr 14 2012 15:59:30 for RTOS - a cooperative multitasking library by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
